<template>
  <div>
    <!-- <h1>注册</h1> -->
    <div>
      <van-cell-group>
        <van-field v-model="user.phone" label="手机号" placeholder="请输入手机号" />
      </van-cell-group>
            <van-cell-group>
        <van-field v-model="user.nickname" label="用户名" placeholder="请输入用户名" />
      </van-cell-group>
            <van-cell-group>
        <van-field v-model="user.password" label="密码" placeholder="请输入密码" />
      </van-cell-group>
      <van-button type="warning"   @click="register">注册</van-button>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import { Toast } from 'vant';

export default {
  data() {
    return {
      value:"",
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods: {
    register() {
      axios({
        url: "/api/register",
        method: "post",
        data: this.user,
      }).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          Toast("注册成功");
          this.$router.push("/login");
        }
      });
    },
  },
};
</script>

<style>
</style>